package com.jishaokang.controller;

import com.jishaokang.base.Result;
import com.jishaokang.model.dto.Course;
import com.jishaokang.model.dto.Learn;
import com.jishaokang.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/**
 * Created by NANA_Final on 2019/6/21.
 */
@RestController
@RequestMapping(value = "/api")
public class CourseController {

    @Autowired
    private CourseService courseService;

    //------------------------------------------------
    @RequestMapping(value = "/all/course/selectCourse",method = RequestMethod.POST)
    public Result selectCourse(@RequestBody Course course) {
        return courseService.selectCourse(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByLearnTotalDesc",method = RequestMethod.POST)
    public Result selectCourseByLearnTotalDescCourse(@RequestBody Course course) {
        return courseService.selectCourseByLearnTotalDesc(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByCostAsc",method = RequestMethod.POST)
    public Result selectCourseByCostAsc(@RequestBody Course course) {
        return courseService.selectCourseByCostAsc(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByCostDesc",method = RequestMethod.POST)
    public Result selectCourseByCostDesc(@RequestBody Course course) {
        return courseService.selectCourseByCostDesc(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByCostFree",method = RequestMethod.POST)
    public Result selectCourseByCostFree(@RequestBody Course course) {
        return courseService.selectCourseByCostFree(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByCourseTimeAsc",method = RequestMethod.POST)
    public Result selectCourseByCourseTimeAsc(@RequestBody Course course) {
        return courseService.selectCourseByCourseTimeAsc(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByCourseTimeDesc",method = RequestMethod.POST)
    public Result selectCourseByCourseTimeDesc(@RequestBody Course course) {
        return courseService.selectCourseByCourseTimeDesc(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByLabelFirst",method = RequestMethod.POST)
    public Result selectCourseByLabelFirst(@RequestBody Course course) {
        return courseService.selectCourseByLabelFirst(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByLabelSecond",method = RequestMethod.POST)
    public Result selectCourseByLabelSecond(@RequestBody Course course) {
        return courseService.selectCourseByLabelSecond(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByLabelThird",method = RequestMethod.POST)
    public Result selectCourseByLabelThird(@RequestBody Course course) {
        return courseService.selectCourseByLabelThird(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByTeacherName",method = RequestMethod.POST)
    public Result selectCourseByTeacherName(@RequestBody Course course) {
        return courseService.selectCourseByTeacherName(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByTeacherId",method = RequestMethod.POST)
    public Result AllSelectCourseByTeacherId(@RequestBody Course course) {
        return courseService.selectCourseByTeacherId(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByCourseNameVague",method = RequestMethod.POST)
    public Result selectCourseByCourseNameVague(@RequestBody Course course) {
        return courseService.selectCourseByCourseNameVague(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByTeacherNameAndCourseNameVague",method = RequestMethod.POST)
    public Result selectCourseByTeacherNameAndCourseNameVague(@RequestBody Course course) {
        return courseService.selectCourseByTeacherNameAndCourseNameVague(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByTeacherNameOrCourseNameVague",method = RequestMethod.POST)
    public Result selectCourseByTeacherNameOrCourseNameVague(@RequestBody Course course) {
        return courseService.selectCourseByTeacherNameOrCourseNameVague(course);
    }

    @RequestMapping(value = "/all/course/selectCourseByCourseId",method = RequestMethod.POST)
    public Result AllSelectCourseByCourseId(@RequestBody Course course) {
        return courseService.selectCourseByCourseId(course);
    }

    //------------------------------------------------------------------
    @RequestMapping(value = "/teacher/course/addCourse",method = RequestMethod.POST)
    public Result addCourse(@RequestBody Course course) {
        return courseService.addCourse(course);
    }

    @RequestMapping(value = "/teacher/course/updateCourse",method = RequestMethod.POST)
    public Result updateCourse(@RequestBody Course course) {
        return courseService.updateCourse(course);
    }

    @RequestMapping(value = "/teacher/course/uploadCourseImage",method = RequestMethod.POST)
    public Result updateCourseImage(@RequestParam String token,@RequestParam Integer courseId, @RequestParam(value = "courseImageFile", required = false) MultipartFile courseImageFile, HttpServletRequest request) throws IOException {
        return courseService.updateCourseImage(token,courseId,courseImageFile,request);
    }

    @RequestMapping(value = "/teacher/course/deleteCourse",method = RequestMethod.POST)
    public Result TeacherDeleteCourse(@RequestBody Course course) {
        return courseService.deleteCourse(course);
    }

    @RequestMapping(value = "/teacher/course/selectCourseByUserId",method = RequestMethod.POST)
    public Result selectCourseByUserId(@RequestBody Course course) {
        return courseService.selectCourseByUserId(course);
    }

    @RequestMapping(value = "/teacher/course/selectCourseByCourseId",method = RequestMethod.POST)
    public Result TeacherSelectCourseByCourseId(@RequestBody Course course) {
        return courseService.selectCourseByCourseId(course);
    }

    //-------------------------------------
    @RequestMapping(value = "/examiner/course/deleteCourse",method = RequestMethod.POST)
    public Result ExaminerDeleteCourse(@RequestBody Course course) {
        return courseService.deleteCourse(course);
    }

    //---------------------------------------
    @RequestMapping(value = "/admin/course/selectCourse",method = RequestMethod.POST)
    public Result AdminSelectCourse(@RequestBody Course course) {
        return courseService.selectCourse(course);
    }
    @RequestMapping(value = "/admin/course/selectCourseByTeacherId",method = RequestMethod.POST)
    public Result AdminSelectCourseByTeacherId(@RequestBody Course course) {
        return courseService.selectCourseByTeacherId(course);
    }

    @RequestMapping(value = "/admin/course/selectCourseByCourseName",method = RequestMethod.POST)
    public Result adminSelectCourseByCourseNameVague(@RequestBody Course course) {
        return courseService.selectCourseByCourseNameVague(course);
    }
}